package com.user.service;

import com.user.dao.UserDao;
import com.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Scope("prototype")
public class UserServiceImpl implements com.user.service.UserService {
    @Autowired
    private UserDao userDao = null;

    @Transactional
    public User selectUser(int id) {
        User user = new User();
        user = userDao.selectUser(id);
        return null;
    }

    @Transactional
    public boolean enter(User user) {
        boolean flag = false;
        User user1 =userDao.selectOne(user.getuName());
        if((user.getuName()).equals(user1.getuName())&&(user.getuPassword()).equals(user1.getuPassword())) {
            return true;
        }else{
            return false;
        }
    }

    @Transactional
    public boolean addUser(User user) {
        boolean flag = userDao.addOne(user);
        flag = true;
        return false;
    }

    @Transactional
    public boolean deleteUser(int id) {
        boolean flag = userDao.deleteOne(id);
        flag = true;
        return false;
    }

    @Transactional
    public boolean updateUser(User user) {
        boolean flag = userDao.updateOne(user);
        flag = true;
        return false;
    }
}
